
// 435.无重叠区间

class Solution {
public:
    int eraseOverlapIntervals(vector<vector<int>>& nums) {
        // 使用贪心来进行解决
        int n = nums.size();
        sort(nums.begin() , nums.end());
        int l = nums[0][0] , r = nums[0][1];
        int ret = 0;
        for(int i = 1 ; i < n ; i++)
        {
            if(nums[i][0] < r)
            {
                r = min(r , nums[i][1]);
                ret++;
            }
            else 
                l = nums[i][0] , r = nums[i][1];
        }
        return ret;
    }
};